﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ActorPanel : MonoBehaviour
{
    public InputField m_Name2;
    public Text m_ID;
    public Text m_DriveLevel;
    public Text m_CharacterL;

    private void OnEnable()
    {
        UpdatePanel();


    }
    void Start()
    {

    }

    void UpdatePanel()
    {

        m_Name2.text = Commander.Instance.m_Name;
        m_ID.text = Commander.Instance.m_ID.ToString();
        m_DriveLevel.text = Player.Instance.m_DriveLevel.ToString();

        //   init character
        m_CharacterL.text = "一个";
        List<string> describe = new List<string>();
        describe.Add("别人都觉得你是一个");
        describe.Add("时不时");
        describe.Add("偶尔");
        describe.Add("有点");
        describe.Add("时而");
        bool isHasCharacter = false;
        for (int i = 0; i < Commander.Instance.m_Characters.Length; ++i)
        {
            var character = Commander.Instance.m_Characters[i];
            if (character == null)
                continue;

            m_CharacterL.text += describe[i] + character.m_Name + "的";
            if (i != Commander.Instance.m_Characters.Length - 1)
                m_CharacterL.text += ",";
            isHasCharacter = true;
        }
        if (!isHasCharacter)
            m_CharacterL.text += "普通的";

        m_CharacterL.text += "人";
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void OnChangedName(string newName)
    {
        Commander.Instance.m_Name = newName;
        Commander.Instance.save();
        MessageShow.Instance.Messaage("你使用 \""+newName+"\" 这个新的名字开始了新的生活!");
    }
}
